import 'package:flutter/material.dart';
import 'package:guangdiu_app/hai_tao.dart';
import 'package:guangdiu_app/home_index.dart';
import 'package:guangdiu_app/hour_rank.dart';

class Main extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return MainWidget();
  }

}

class MainWidget extends State<Main>{

  int _index=0;

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      body: IndexedStack(
        children: <Widget>[
          HomeIndex(),
          HaiTao(),
          HourRank()
        ],
        index: _index,
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.home,color: Colors.grey,),
            title: Text("首页",style: TextStyle(color: _index==0?Colors.green:Colors.grey),),
            activeIcon: Icon(Icons.home,color: Colors.green,),
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.flight_takeoff,color: Colors.grey,),
            title: Text("海淘",style: TextStyle(color: _index==1?Colors.green:Colors.grey),),
            activeIcon: Icon(Icons.flight_takeoff,color: Colors.green,),
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.timer,color: Colors.grey,),
            title: Text("小时风云榜",style: TextStyle(color: _index==2?Colors.green:Colors.grey),),
            activeIcon: Icon(Icons.timer,color: Colors.green,),
          ),
        ],
        currentIndex: _index,
        onTap: (index){
          setState(() {
            _index=index;
          });
        },
      ),
    );
  }

}